﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace MyQQ.Message
{
    /// <summary>
    /// 标记接收方的姓名
    /// </summary>
    [Serializable]
    class ToWhoMessage
    {
        public string name;
        public string Name
        {
            get
            {
                return name;
            }
        }
        public ToWhoMessage(string name)
        {
            this.name = name;
        }
    }


    /// <summary>
    /// 标记发送方的姓名
    /// </summary>
    [Serializable]
    class FromWhoMessage
    {
        public string name;
        public string Name
        {
            get
            {
                return name;
            }
        }
        public FromWhoMessage(string name)
        {
            this.name = name;
        }
    }

    /// <summary>
    /// 标记登陆信息
    /// </summary>
    [Serializable]
    class LoginMessage
    {
        private string name;
        private string password;

        public string Name
        {
            get 
            {
                return name;
            }
        }

        public string Password
        {
            get
            {
                return password;
            }
        }

        /// <summary>
        /// 用来标记是否登入成功
        /// </summary>
        public bool success;

        public LoginMessage(string name, string password)
        {
            this.name = name;
            this.password = password;
            success = false;
        }

    }
    
    /// <summary>
    /// 标记注册信息
    /// </summary>
    [Serializable]
    class RegisterMessage
    {
        private string name;
        private string password;

        public string Name
        {
            get
            {
                return name;
            }
        }

        public string Password
        {
            get
            {
                return password;
            }
        }

        /// <summary>
        /// 用来标记是否注册成功
        /// </summary>
        public bool success;

        public RegisterMessage(string name, string password)
        {
            this.name = name;
            this.password = password;
            success = false;
        }

    }

    /// <summary>
    /// 标记登陆用户所在IP信息
    /// </summary>
    [Serializable]
    class IpMessage
    { 
        private string ip;
        private int port;

        public string IP
        {
            get
            {
                return ip;
            }
        }

        public int Port
        {
            get
            {
                return port;
            }
        }

        public IpMessage(string ip, int port)
        {
            this.ip = ip;
            this.port = port;
        }
    }

    [Serializable]
    public enum MessageType
    {
        Login,
        Register,
        Message,
        IsActive,
        //AskInfo
    }

    [Serializable]
    class Message
    {
        public MessageType Type;

        public ToWhoMessage Towho
        {
            get;
            set;
        }

        public FromWhoMessage FromWho
        {
            get;
            set;
        }

        public LoginMessage Login;

        public RegisterMessage Register;

        public IpMessage IP;

        //标记活动用户
        public List<string> ActiveName;
        public List<string> InActiveName;

        public bool IsLive = false;
        public string ChatInfo;
    }

}